package com.xmh.reptile.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.xmh.reptile.entity.SexVideoEntity;
import com.xmh.reptile.service.SexVideoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author xiaominghui
 * @Date 2020-10-16 18:28:47
 */
@Api(tags = "SexVideoController")
@RestController
@RequestMapping(value = "/API/sexVideo", produces = "application/json;charset=UTF-8")
@Transactional
@CrossOrigin
public class SexVideoController {

	@Autowired
	private SexVideoService sexVideoService;

	/**
	 * 保存数据接口
	 * 
	 * @param jsonMap
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/save", method = RequestMethod.POST)
	@ApiOperation(value = "保存接口", notes = "参数 ： ")
	@ResponseBody
	public Map<String, Object> save(@RequestBody Map<String, Object> jsonMap) throws Exception {
		SexVideoEntity sexVideoParameter = new SexVideoEntity(jsonMap);

		return sexVideoService.add(sexVideoParameter);
	}

	/**
	 * 根据给定数据条件删除数据，不一定根据id删除
	 * 
	 * @param jsonMap
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/delete", method = RequestMethod.POST)
	@ApiOperation(value = "删除接口", notes = "参数 ： ")
	@ResponseBody
	public Map<String, Object> delete(@RequestBody Map<String, Object> jsonMap) throws Exception {
		SexVideoEntity sexVideoParameter = new SexVideoEntity(jsonMap);

		return sexVideoService.delete(sexVideoParameter);
	}

	/**
	 * update修改接口，根据唯一id进行修改
	 * 
	 * @param jsonMap
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	@ApiOperation(value = "修改接口", notes = "参数 ： ")
	@ResponseBody
	public Map<String, Object> update(@RequestBody Map<String, Object> jsonMap) throws Exception {
		SexVideoEntity sexVideoParameter = new SexVideoEntity(jsonMap);

		return sexVideoService.update(sexVideoParameter);
	}

	/**
	 * 查找多条数据，条件可以为空，默认查找全部
	 * 
	 * @param jsonMap
	 * 
	 *                <pre>
	 *	pageIndex 页数下标  
	 *	pageNumber 每页数量
	 *                </pre>
	 * 
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/selectList", method = RequestMethod.POST)
	@ApiOperation(value = "获取列表接口", notes = "参数 ： ")
	@ResponseBody
	public Map<String, Object> selectList(@RequestBody Map<String, Object> jsonMap) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();

		map.put("list", sexVideoService.selectList(jsonMap));

		return map;
	}

	/**
	 * 根据指定条件获取单条数据
	 * 
	 * @param jsonMap
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/get", method = RequestMethod.POST)
	@ApiOperation(value = "获取单体数据接口", notes = "参数 ： ")
	@ResponseBody
	public Map<String, Object> get(@RequestBody Map<String, Object> jsonMap) throws Exception {
		SexVideoEntity sexVideoParameter = new SexVideoEntity(jsonMap);

		Map<String, Object> map = new HashMap<String, Object>();

		map.put("entity", sexVideoService.get(sexVideoParameter));

		return map;
	}

}
